package com.icss.clothes.service.imp;

import com.icss.clothes.entity.Color;
import com.icss.clothes.entity.Shop;
import com.icss.clothes.entity.Shopdetail;
import com.icss.clothes.mapper.ShopMapper;
import com.icss.clothes.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ShopService implements IShopService {
    @Autowired
    private ShopMapper shopMapper;

//    @Override
//    public List<Shop> findByType_id(int type_id) {
//        //从数据库中通过指定的类别名称查询得到所有满足过滤条件的商品列表
//        return shopMapper.selectByType_id(type_id);
//    }
//
//    @Override
//    public int findByType_name(String type_name) {
//        return shopMapper.selectByType_name(type_name);
//    }

    @Override
    public List<Shop> findAll() {
        //从数据库中查询得到所有的商品
        return shopMapper.selectAll();
    }

    @Override
    public List<Shop> findAllSearch(Shop shopSearch) {
        return shopMapper.selectAllSearch(shopSearch);
    }

    //展现特色商品--通过备注检索
    public List<Shop> findBycomment(String comment){
        return shopMapper.findBycomment(comment);
    }


    //获取最新上架、最高销量、最佳评分
    public List<Shop> findCommodityBySort(int sortid){
        //最新上架，通过时间排序
        List<Shop> commodityList=null;
        if (sortid==1){
             commodityList= shopMapper.findCommodityBySort("c_createtime");
        }else if (sortid==0) {
            //最佳销售，通过销量排序
            commodityList= shopMapper.findCommodityBySort("sale_number");
        }else if (sortid==2 ){
            //最高评分，通过评分排序
             commodityList= shopMapper.findCommodityBySort("remark_score");
        }
        return commodityList;
    }
    //从数据库中通过最高销量升序排序查询得到所有商品信息
    @Override
    public List<Shop> findAllBySale_number() {
        return shopMapper.selectAllBySale_number();
    }

    @Override
    public List<Shopdetail> findAllByC_cid(int c_id) {
        //从数据库中通过指定的商品编号查询得到商品的详情信息
        return shopMapper.selectAllByC_cid(c_id);
    }

    @Override
    public List<Color> findAllColorByC_id(int c_id) {
        //从数据库中通过指定的商品编号查询得到所有商品的颜色信息
        return shopMapper.selectAllColorByC_id(c_id);
    }

    @Override
    public List<Shopdetail> findByCidAndColorId(int color_id, int c_id) {
        return shopMapper.selectByCidAndColorId(c_id,color_id);
    }

    @Override
    public double findByCidAndSizeId(int c_id, int size_id) {
        return shopMapper.selectByCidAndSizeId(c_id,size_id);
    }

    @Override
    public Shop findById(int id) {
        return shopMapper.selectById(id);
    }

    @Override
    public List<Shopdetail> selectAllByNumberAndCd_id() {
        //从数据库中查询得到所有商品详情信息
        return shopMapper.selectAllByNumberAndCd_id();
    }

}
